package cn.stylefeng.guns.modular.yingbao.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.yingbao.entity.SysBuilding;
import cn.stylefeng.guns.modular.yingbao.model.params.SysBuildingParam;
import cn.stylefeng.guns.modular.yingbao.service.SysBuildingService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 建仓订单表控制器
 *
 * @author jj
 * @Date 2019-12-18 13:51:40
 */
@CrossOrigin
@Controller
@RequestMapping("/sysBuilding")
@Api(tags = "建仓")
public class SysBuildingController extends BaseController {

    private String PREFIX = "/sysBuilding";

    @Autowired
    private SysBuildingService sysBuildingService;

    /**
     * 跳转到主页面
     *
     * @author jj
     * @Date 2019-12-18
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/sysBuilding.html";
    }

    /**
     * 新增页面
     *
     * @author jj
     * @Date 2019-12-18
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/sysBuilding_add.html";
    }

    /**
     * 编辑页面
     *
     * @author jj
     * @Date 2019-12-18
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/sysBuilding_edit.html";
    }

    /**
     * 新增接口
     *
     * @author jj
     * @Date 2019-12-18
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(SysBuildingParam sysBuildingParam) {
        this.sysBuildingService.add(sysBuildingParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author jj
     * @Date 2019-12-18
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(SysBuildingParam sysBuildingParam) {
        this.sysBuildingService.update(sysBuildingParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author jj
     * @Date 2019-12-18
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(SysBuildingParam sysBuildingParam) {
        this.sysBuildingService.delete(sysBuildingParam);
        return ResponseData.success();
    }
    /**
     * 建仓
     *
     * @author jj
     * @Date 2019-12-18
     */
    @ApiOperation("建仓")
    @RequestMapping(value = "/appBuilding",method = RequestMethod.POST)
    @ResponseBody
    public ResponseData building(Long userid, Long price) {
        return sysBuildingService.building(userid, price);
    }

    /**
     * 查看建仓
     *
     * @author jj
     * @Date 2019-12-18
     */
    @ApiOperation("查看建仓")
    @RequestMapping(value = "/appBuildingLook",method = RequestMethod.POST)
    @ResponseBody
    public ResponseData buildingLook(Long userid,String ordinal,String stuats) {
        return sysBuildingService.buildingLook(userid, ordinal,stuats);
    }

    /**
     * 查看建仓
     *
     * @author jj
     * @Date 2019-12-18
     */
    @ApiOperation("查看建仓列表")
    @RequestMapping(value = "/appBuildingListLook",method = RequestMethod.POST)
    @ResponseBody
    public ResponseData buildingListLook(Long userid,String stuats) {
        return sysBuildingService.buildingListLook(userid,stuats);
    }
    /**
     * 查看详情接口
     *
     * @author jj
     * @Date 2019-12-18
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(SysBuildingParam sysBuildingParam) {
        SysBuilding detail = this.sysBuildingService.getById(sysBuildingParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author jj
     * @Date 2019-12-18
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(SysBuildingParam sysBuildingParam) {
        return this.sysBuildingService.findPageBySpec(sysBuildingParam);
    }

    /**
     * 团队盈利
     *
     * @author jj
     * @Date 2019-12-18
     */
    @ResponseBody
    @ApiOperation("团队业绩" )
    @RequestMapping(value = "/groupEarnings",method = RequestMethod.POST)
    public ResponseData groupEarnings(Long userid,int pageNum,int pageSize) {
        return this.sysBuildingService.groupEarnings(userid,pageNum,pageSize);
    }
    /**
     * 团队盈利
     *
     * @author jj
     * @Date 2019-12-18
     */
    @ResponseBody
    @ApiOperation("团队结果" )
    @RequestMapping(value = "/group",method = RequestMethod.POST)
    public ResponseData group(Long userid ) {
        return this.sysBuildingService.group(userid);
    }

}


